package com.sakura.mybatis.factory;

import com.sakura.mybatis.config.Configuration;
import com.sakura.mybatis.executor.Executor;
import com.sakura.mybatis.executor.SimpleExecutor;
import com.sakura.mybatis.session.DefaultSqlSession;
import com.sakura.mybatis.session.SqlSession;

/**
 * @author wangxinyuchuan
 * @version DefaultSqlSessionFactory.java v1.0 2025/4/15 15:38 wangxinyuchuan Exp $
 */
public class DefaultSqlSessionFactory implements SqlSessionFactory {

    // 全局配置类
    private final Configuration configuration;

    public DefaultSqlSessionFactory(Configuration configuration) {
        this.configuration = configuration;
    }

    @Override
    public SqlSession openSession() {
        Executor simpleExecutor = new SimpleExecutor();
        return new DefaultSqlSession(configuration, simpleExecutor);
    }
}
